﻿using UnityEngine;
using System.Collections;

public class B_Comecar : MonoBehaviour {

	int id = 79;
	
	string cena;
	
	void Awake()
	{
		cena = Application.loadedLevelName;
		this.transform.Translate(-0.3f,-2.1f,0.0f);
		this.gameObject.AddComponent("MeshRenderer");
		this.gameObject.AddComponent("MeshFilter");

	}
	
	void Start () 
	{

		Mesh mesh = Quad.Create(1.3f, 0.358f);
		
		this.gameObject.GetComponent<MeshFilter>().mesh = mesh;
		this.gameObject.GetComponent<MeshRenderer>().material = AtlasManager.globalMaterial;
		
		this.gameObject.GetComponent<MeshFilter>().mesh.uv = new Vector2[]
		{
			new Vector2(AtlasManager.rects[id].xMin, AtlasManager.rects[id].yMax),
			new Vector2(AtlasManager.rects[id].xMax, AtlasManager.rects[id].yMax),
			new Vector2(AtlasManager.rects[id].xMax, AtlasManager.rects[id].yMin),
			new Vector2(AtlasManager.rects[id].xMin, AtlasManager.rects[id].yMin)
		};
	
	}
	
	void Update () {
	
	}
	
	void OnMouseEnter()
	{
		id = 80;
		Start();
	}
	
	void OnMouseExit()
	{
		id = 79;
		Start();
	}
	
	void OnMouseDown()
	{
		if(cena == "Sinopse")
		{
			Application.LoadLevel("Game");	
		}
		else
		{		
		Application.LoadLevel("Periodo");
			SceneManager.PlayerDead = false;
			Pontos.Pontuacao = 0;
			TimeCounter.Hora = 0;
			TimeCounter.Minutos = 0;
			TimeCounter.Dia = 0;
		}
	}
	
}


